<?php
/*
 +----------------------------------------------------------------------
 + Title        : MyRedis 控制器
 + Author       : Randy_chen
 + Version      : V1.0.0.1
 + Initial-Time : 2019/9/2 9:57
 + Last-time    : 2019/9/2 9:57+ 86187
 + Desc         : MyRedis
 +----------------------------------------------------------------------
*/


namespace randy\queue;


class MyRedis {
	private static $instance = null;
	private $setting = [];

	private function __construct() {
	}

	private function __clone() {
	}

	public static function getInstance() {

		if (self::$instance == null) {
			$redis = new \Redis();
			$config['host'] = '127.0.0.1';
			$config['port'] = '6379';
			$config['select'] = 5;
			$config['password'] = 'jielong';
			$redis->connect($config['host'], $config['port']);
			if ($config['password']) {
				$redis->auth($config['password']);
			}
			if ($select = $config['select']) {
				$redis->select($select);
			}
			self::$instance = $redis;
		}
		return self::$instance;
	}

	public function set($index, $value) {
		$this->setting[$index] = $value;
	}

	public function get($index) {
		return $this->setting[$index];
	}
}